package com.sicheng.lc.周赛.分类.思维;

/**
 * @author zsc
 * @version 1.0
 * @date 2022/7/2 22:29
 */
public class 得到目标值的最少行动次数 {
    //https://leetcode.cn/problems/minimum-moves-to-reach-target-score/
    public int minMoves(int target, int maxDoubles) {
        int count = 0;
        while (target != 1) {
            if (target % 2 == 0) {
                if (maxDoubles > 0) {
                    target /= 2;
                    maxDoubles--;
                    count++;
                } else break;
            } else {
                target--;
                count++;
            }
        }


        return count + target - 1;
    }
}
